<template>
  <div class="app-container">
    <el-form :inline="true" ref="ruleForm"  :model="formInline" class="demo-form-inline">
      <el-form-item>
        <el-col>
          <el-form-item prop="time" label="日期">
            <el-date-picker
              v-model="formInline.time"
              type="daterange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期"
              value-format="yyyy-MM-dd"
              :default-time="['00:00:00', '23:59:59']"
              :picker-options="pickerWeekStep">
            </el-date-picker>
          </el-form-item>
        </el-col>
      </el-form-item>
      <el-button class="filter-item" type="primary" icon="el-icon-search" @click="toSearch">搜索
      </el-button>
      <el-button type="primary" @click="handleExport">导出</el-button>
    </el-form>
  </div>

</template>
<script>
import { form, grid, pickerOption } from '@/build';

export default {
  name: 'form-filter',
  mixins: [form, grid, pickerOption],
  data() {
    return {
      formInline: {
        time: [
          moment().format('YYYY-MM-DD'),
          moment().format('YYYY-MM-DD'),
        ],
      },
    };
  },
  methods: {
    toSearch() {
      this.$emit('on-filter', this.formInline);
    },
    selfResetForm(formName) {
      this.resetForm(formName);
      this.$emit('on-filter', this.formInline);
    },
    handleExport() {
      this.$emit('handleExport', this.formInline);
    },
  },
  mounted() {
    // window.addEventListener('keyup', (e) => {
    //   const event = e || window.event;
    //   const code = event.keyCode || event.which || event.charCode;
    //   if (code == 13) {
    //     this.toSearch();
    //   }
    // });
  },
};
</script>

<style lang="scss" scoped>
 .mgtop{margin-top:30px}
</style>
